<template>
  <div>
    <div class="dy-container">
      <!-- 图标 -->
      <div class="dy-header">
        <img src="../../assets/img/logo.png" alt />
      </div>

      <div>
        <!-- 输入框 -->
        <div class="dy-inp">
          <input type="text" placeholder="请输入手机号" v-model="getInfo.mobile"/>
        </div>

        <!-- 输入框 -->
        <div class="dy-inp">
          <input type="password" placeholder="请输入密码" v-model="getInfo.pass"/>
        </div>

        <!-- 找回密码，登录注册切换 -->
        <div class="dy-mi">
          <span @click="pass">找回密码</span>
          <span @click="tog">注册/验证码登录</span>
        </div>

        <!-- 登录 -->
        <button class="dy-btn" @click="login">登录</button>
      </div>
    </div>
  </div>
</template>

<script>
import {Login} from '../../request/http'
export default {
  name: "",
  data() {
    return {
      dy_show: true,
      getInfo:{
          mobile:"",
          pass:"",
      },
    };
  },
  props: [],
  components: {},
  mounted() {
    document.body.style.background = "#fff";
    localStorage.removeItem("adminToken");
    localStorage.removeItem("user_id");
  },
  methods: {
    tog() {
      this.$router.push({path:'/register'})
    },
    pass() {
      this.$router.push({ path: "/password" });
    },
    login(){
      let obj={
        mobile:this.getInfo.mobile,
        password:this.getInfo.pass,
        type:1
      };
      Login(obj).then(res=>{
        console.log(res)
        if(res.data.code===200){
          localStorage.setItem("adminToken", res.data.data.remember_token);
            localStorage.setItem("user_id", res.data.data.id);
            this.$toast.success(res.data.msg);
            this.$router.push("/my");
        }else if(res.data.code===201){
          this.$toast.fail(res.data.msg)
        }
      })
    }
  }
};
</script>

<style scoped>
.dy-container {
  width: 100%;
  height: 650px;
  background: #fff;
  padding: 0px 20px;
  box-sizing: border-box;
}
.dy-header {
  width: 100%;
  height: 150px;
  /* background: #000; */
  text-align: center;
  line-height: 200px;
}
.dy-header > img {
  width: 246px;
  height: 51px;
}
.dy-inp {
  height: 13.33333vw;
  background-color: #fff;
  border-bottom: 1px solid #f1f1f1;
  /* padding: 0 20px; */
  position: relative;
}
.dy-inp > input {
  box-sizing: border-box;
  padding: 0.4rem 0;
  padding: 4vw 0;
  border: 0;
  /* width: 7.2rem; */
  width: 72vw;
  height: 100%;
  font-size: 0.4rem;
  font-size: 4vw;
  font-family: PingFangSC-Regular;
  font-weight: 400;
  line-height: 0.53333rem;
  line-height: 5.33333vw;
  float: left;
  outline: none;
}
.dy-inp > div {
  color: #fd5d0b;
  top: 15px;
  right: 0;
}
.dy-mi {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  color: #999999;
}
.dy-btn {
  width: 98%;
  height: 45px;
  border-radius: 25px;
  border: none;
  outline: none;
  background: linear-gradient(to right, rgb(240, 163, 91), #fd5d0b);
  color: #fff;
  font-size: 14px;
  margin-top: 50px;
}
</style>